﻿@using PagedList
@model PagedList.IPagedList<ShenLanCMS.Models.Tag>
@{
    ViewBag.Title = "标签管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<fieldset>
    <legend>标签管理</legend>
    <br />
    <table>
        <tr>
            <th>
                标签名称
            </th>
            <th>
                数量
            </th>
            <th>
                操作
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.TagName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Num)
                </td>
                <td>
                    <a href="javascript:delTag('@item.TagID')">删除</a>
                </td>
            </tr>
        }
    </table>
        <div style="width: auto; height: 30px; margin-top: 10px; text-align: left;">
        @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
        / @Model.PageCount
        &nbsp;
        @if (Model.HasPreviousPage)
        {
            @Html.ActionLink("首页", ViewData["actionName"].ToString(), new { page = 1, keyword = ViewData["keyword"] })
            @Html.Raw("&nbsp;");
            @Html.ActionLink("< 上一页", ViewData["actionName"].ToString(), new { page = Model.PageNumber - 1, keyword = ViewData["keyword"] })
        }
        else
        {
            @Html.Raw("首页&nbsp;&nbsp;上一页")
        }
        &nbsp;
        @if (Model.HasNextPage)
        {
            @Html.ActionLink("下一页 >", ViewData["actionName"].ToString(), new { page = Model.PageNumber + 1, keyword = ViewData["keyword"] })
            @Html.Raw("&nbsp;");
            @Html.ActionLink("尾页", ViewData["actionName"].ToString(), new { page = Model.PageCount, keyword = ViewData["keyword"] })
        }
        else
        {
            @Html.Raw("下一页&nbsp;&nbsp;尾页")
        }
    </div>
</fieldset>
<script type="text/javascript">
    function delTag(obj) {
        if (confirm("确定要删除该标签吗?")) {
            $.post("/tag/delete/" + obj, function (data) {
                alert(data);
                if (data == "删除成功")
                    window.location.reload();
            }); 
        }
    }
</script>